package com.kevin.validation.controller;

import com.kevin.validation.group.Add;
import com.kevin.validation.group.Cus;
import com.kevin.validation.group.Edit;
import com.kevin.validation.model.UserDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@Tag(name = "数据校验")
@RequestMapping("/validation")
public class ValidationController {

    @Operation(summary = "新增", description = "新增")
    @PostMapping
    public Object add(@Validated(value = Add.class) @RequestBody UserDTO userDTO) {
        System.err.println(userDTO);
        return userDTO;
    }

    @Operation(summary = "编辑", description = "编辑")
    @PutMapping
    public Object edit(@Validated(value = Edit.class) @RequestBody UserDTO userDTO) {
        System.err.println(userDTO);
        return userDTO;
    }

    @Operation(summary = "重置", description = "重置")
    @PatchMapping
    public Object reset(@Validated(value = Cus.class) @RequestBody UserDTO userDTO) {
        System.err.println(userDTO);
        return userDTO;
    }

}
